package com.suyl.candy.impexcel.converter;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

/**
 * 类别字典
 *
 * @author suyanlong
 * @version 1.0
 * @createDate 2020/4/21 22:18
 */
public class CatgroyConverter implements Converter<String> {
    public static final String HUAX = "花销"; // 1
    public static final String SHOR = "收入"; // 2
    public static final String QITA = "其他"; // 3

    @Override
    public Class supportJavaTypeKey() {
        return String.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.STRING;
    }

    @Override
    public String convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        String stringValue = cellData.getStringValue();
        if (HUAX.equals(stringValue)) {
            return "1";
        } else if (SHOR.equals(stringValue)) {
            return "2";
        } else {
            return "3";
        }
    }

    @Override
    public CellData convertToExcelData(String s, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        return null;
    }
}
